"""Usefull functions."""

import os
import sys
import urllib

def die(message="", status=1):
    "Prints message to STDERR and exit with status"
    sys.stderr.write(message)
    sys.exit(status)

def shift(lst):
    "Shifts the first value of the sequence off and returns it"
    lst.reverse()
    elem = lst.pop()
    lst.reverse()
    return elem

def unshift(lst, elem):
    "Does the opposite of a shift"
    lst.insert(0, elem)

def retrieve(url):
    "Retrieve content from URL"
    handler = urllib.urlopen(url)
    content = handler.read()
    handler.close()
    return content
